package com.guigu.leizihao.controller;

import com.guigu.common.pojo.DFile;
import com.guigu.common.pojo.SCell;
import com.guigu.common.pojo.SGather;
import com.guigu.common.pojo.SGatherDetails;
import com.guigu.leizihao.vo.SGatherDetailsView;
import com.guigu.leizihao.vo.SGatherVo;
import com.guigu.common.vo.SearchVo;
import com.guigu.leizihao.service.SGatherService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;


@Controller
@RequestMapping("/sgather")
public class SGatherController {

    @Resource
    public SGatherService sGatherService;


    /**
     * 查询未调度的入库申请单
     * @param searchVo
     * @return
     */
    @RequestMapping("/queryGather")
    @ResponseBody
    public SearchVo queryGather(@RequestBody SearchVo searchVo){
        System.out.println(searchVo);
        return this.sGatherService.queryGather(searchVo);

    }


    /**
     * 查询产品库存已分配的所有产品
     * @param searchVo
     * @return
     */
    @RequestMapping("/findDfileInDESIGN_CELL_TAG")
    @ResponseBody
    public SearchVo findDfileInDESIGN_CELL_TAG(SearchVo searchVo){
        SearchVo<DFile> dfileInDESIGN_cell_tag = this.sGatherService.findDfileInDESIGN_CELL_TAG(searchVo);

        return dfileInDESIGN_cell_tag;

    }


    /**
     * 添加入库单和入库明细
     * @param sGatherVo
     * @return
     */
    @RequestMapping("/addGatherApplyFor")
    @ResponseBody
    public int addGather(@RequestBody SGatherVo<SGatherDetails> sGatherVo){
        System.out.println(sGatherVo);
        this.sGatherService.addGather(sGatherVo);
        return 1;
    }

    /**
     * 查询所有待审核的入库单
     * @param searchVo
     * @return
     */
    @RequestMapping("/queryGatherToAudit")
    @ResponseBody
    public SearchVo queryGatherToAudit(SearchVo searchVo){

        SearchVo s= this.sGatherService.queryGatherToAudit(searchVo);
        return s;
    }

    /**
     * 根据入库单序号查询入库明细
     * @param id
     * @return
     */
    @RequestMapping("/findGatherDetailsById")
    @ResponseBody
    public List<SGatherDetails> findGatherDetailsById(Integer id){
        return this.sGatherService.findGatherDetailsById(id);
    }


    @RequestMapping("/findGatherDetailsByIdandQuantityIinStorage")
    @ResponseBody
    public List<SGatherDetails> findGatherDetailsByIdandQuantityIinStorage(Integer id){
            return this.sGatherService.findGatherDetailsByIdandQuantityIinStorage(id);
    }


    /**
     * 通过审核
     * @param sGather
     * @return
     */
    @RequestMapping("/changeSGather")
    @ResponseBody
    public int changeSGather(@RequestBody SGather sGather){

        System.out.println(sGather);
      int i=  this.sGatherService.changeSGather(sGather);

      return 1;
    }

    /**
     * 审核不通过
     * @param id
     * @return
     */
    @RequestMapping("/changeSGatherNo")
    @ResponseBody
    public int changeSGatherNo(Integer id){

        int i=  this.sGatherService.changeSGatherNo(id);

        return 1;
    }

    /**
     * 查询所有的入库单
     * @param searchVo
     * @return
     */
    @RequestMapping("/queryGatherAll")
    @ResponseBody
    public SearchVo queryGatherAll(SearchVo searchVo ){
       return this.sGatherService.queryGatherAll(searchVo);
    }

    /**
     * 查询所有通过审核的入库单
     * @param searchVo
     * @return
     */
    @RequestMapping("/findFormulateGather")
    @ResponseBody
    public SearchVo findFormulateGather(SearchVo searchVo){
       return this.sGatherService.findFormulateGather(searchVo);
    }


    /**
     * 根据产品编号查询对应的安全配置单
     * @param productid
     * @return
     */
    @RequestMapping("/queryCellByProductId")
    @ResponseBody
    public SCell queryCellByProductId(String productid){
        return this.sGatherService.queryCellByProductId(productid);
    }

    /**
     * 更改调度后的明细状态
     * @param id
     * @return
     */
    @RequestMapping("/UpdateGather_details")
    @ResponseBody
    public int UpdateGather_details(Integer id){
        int i=this.sGatherService.UpdateGather_details(id);
        return 1;
    }

    /**
     * 提交登记入库数量
     */
    @RequestMapping("/updateGather_detailsQuantityInStorage")
    @ResponseBody
    public int updateGather_detailsQuantityInStorage(@RequestBody SGatherVo sGatherVo){
        System.out.println(sGatherVo);
        this.sGatherService.updateGather_detailsquantityInStorage(sGatherVo);
        return 1;
    }

    @RequestMapping("/queryEnterbankCheck")
    @ResponseBody
    public SearchVo queryEnterbankCheck(SearchVo searchVo){
        return this.sGatherService.queryEnterbankCheck(searchVo);
      }


    /**
     * 入库登记审核通过
     * @param sGatherVo
     * @return
     */
    @RequestMapping("/EnterbankCheckPass")
      @ResponseBody
    public int EnterbankCheckPass(@RequestBody SGatherVo<SGatherDetails> sGatherVo){
        System.out.println(sGatherVo);
        this.sGatherService.EnterbankCheckPass(sGatherVo);
        return 1;
    }

    @RequestMapping("/queryTotalcost")
    @ResponseBody
    public Integer queryTotalcost(Integer id){
        return this.sGatherService.queryTotalcost(id);
    }


    @RequestMapping("/queryGatherDetailsByproductId")
    @ResponseBody
    public List<SGatherDetailsView> queryGatherDetailsByproductId(String productid){
        return this.sGatherService.queryGatherDetailsByproductId(productid);
    }

}

